<? session_start();?>
<?=$this->load->view('user_include_top',null)?>  
<div style="width:900px; line-height:30px; margin:0 auto">
  <p><a href="<?=base_url()?>">首页</a> > <a href="<?=base_url()?>site/feedback#">联系我们</a></p>
</div>
<div style="width:900px; margin:0px auto; "> <img src="images/bar03.jpg" />
   <?
   if($_SESSION['user_name'] == "admin") {
   ?>
  <table width='100%' border='0' cellspacing='0' cellpadding='0'>
   <?
   foreach($list as $row) {?>
    <tr>
      <td width='100' align='center' valign='top' style="font-size: 15px;color:#444"><br>
        <?=$row->user_name?><br>
        <font style="font-size:12px">
        [<a href="<?=base_url()?>/site/del_feedback/<?=$row->id?>" onclick="return confirm('确定要删除吗？')">删除</a>]
        </font>
        </td>
      <td width='6'></td>
      <td width='600' valign='top' style="border-bottom:#ddd 1px solid"><table width='100%' border='0' cellspacing='0' cellpadding='2'>
          <tr height='24'>
            <td width='72%'><font color='#ff3300'><?=$row->title?></font></td>
            <td width='28%' style="color:gray"><img src='images/date.gif' style="vertical-align:middle">&nbsp;<?=$row->post_date?></td>
          </tr>
          <tr>
            <td colspan='2'></td>
          </tr>
          <tr height='40' valign='top'>
            <td colspan='2' bgcolor='#FFFFFF'> <?=$row->content?></td>
          </tr>
        </table></td>
    </tr>
   <?}?>
    <tr>
      <td align='center' valign='top'>&nbsp;</td>
      <td></td>
      <td valign='top'>&nbsp;</td>
    </tr>
    
    <tr>
      <td align='center' valign='top'></td>
      <td>
      <td colspan='3' align='right'><?=$page_links?></td>
    </tr>
  </table>
  <br />
  <?} else {?>
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
     <form name="f">
      <tr>
        <td width="69">主　　题：</td>
        <td width="460"><input name="title" type="text" class="TextBox" id="title" size="40" maxlength="100" /></td>
      </tr>
      <tr>
        <td>留言内容：</td>
        <td><textarea name="content" id="content" cols="72" rows="8" class="TextBox"></textarea></td>
      </tr>
      <tr>
        <td>留&nbsp;言&nbsp;人：</td>
        <td><input name="user_name" type="text" class="TextBox" id="user_name" value="" size="20" maxlength="50" /></td>
      </tr>
      <tr>
        <td>电子邮箱：</td>
        <td><input name="email" type="text" class="TextBox" id="email" value="" size="30" maxlength="50" /> <font color=gray>[可选]</font></td>
      </tr>
      <tr>
        <td height="40">&nbsp;</td>
        <td><input id="btn_submit" type="button" class="button" value=" 保存 " onclick="do_post()"/>
          &nbsp;
          <input id="btn_reset" type="reset" class="button" value=" 重置 " /></td>
      </tr>
      </form>
  </table>
  <? } ?>
</div>
<script>
    function do_post() {
        var f = document.f;
        if($('#title').val() == '' || $('#content').val() == '') {
            alert('请填写留言主题及内容！');
            return false;
        }
        if($('#user_name').val() == '') {
            alert('请填写留言人称呼！');
            return false;  
        }
        var params = {'title':$('#title').val(),'content':$('#content').val(),'user_name':$('#user_name').val(),'email':$('#email').val()}
        $('#btn_submit').attr('disabled', true);
        $('#btn_submit').val('提交中...');   
        $.post("<?=base_url()?>site/post_feedback", params, function(data) {
            if(data == "ok") {
                alert("留言提交成功，感谢您的支持！");
                f.reset();
                $('#btn_submit').attr('disabled', false);
                $('#btn_submit').val(' 保存 ');   
            } else {
                alert("错误提示 >>> " + data)
            }
        })  
    }
</script>
<?=$this->load->view('user_include_bottom',null)?>  
